﻿using INTEX.DataBase.Tools;
using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Linq;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class ITXEXRPT
    { 
         
        private void TSTVK05(DataSet db)  
        {
            try
            {
                DataTable tbVKKOPF = dsSource.Tables["VKKOPF"];
                DataRow dwVKKOPF = tbVKKOPF.Rows[0];
                string src = "";

                src = dwVKKOPF["ORDERNO"].ToString();
                exAgent.SetCellValue(6, 38, src);
                src = dwVKKOPF["VKKBESTNR"].ToString().Trim();
                exAgent.SetCellValue(8, 38, Helper.GetGB2312Value(src).Trim());
                src = dwVKKOPF["CUSTOMER"].ToString().Trim();
                exAgent.SetCellValue(8, 4, Helper.GetGB2312Value(src).Trim());
                src = dwVKKOPF["PAYMENT"].ToString().Trim();
                exAgent.SetCellValue(82, 8, Helper.GetGB2312Value(src).Trim());
                src = dwVKKOPF["TOT"].ToString().Trim();
                exAgent.SetCellValue(58, 10, Helper.GetGB2312Value(src).Trim());
                src = dwVKKOPF["CURRENCY"].ToString().Trim();
                exAgent.SetCellValue(14, 35, "总金额 ("+Helper.GetGB2312Value(src).Trim()+")");

                int x = 16;
                string ART = "", KART = "", COLOR = "", KCOLOR = "";
                foreach (DataRow dwVKPOS in tbVKKOPF.Rows)
                {
                    src = dwVKPOS["VKPAUFPOS"].ToString();
                    exAgent.SetCellValue(x, 1, System.Convert.ToInt64(src));
                    ART = Helper.GetGB2312Value(dwVKPOS["VKPART"].ToString().Trim() + "-" + dwVKPOS["VAABEZ"].ToString().Trim());
                    KART = Helper.GetGB2312Value(dwVKPOS["VKPKDARTNR"].ToString().Trim());
                    if (KART != "")
                    {
                        src = ART + System.Environment.NewLine + "客户品种:" + KART;
                    }
                    else
                    {
                        src = ART;
                    }                    
                    exAgent.SetCellValue(x, 3, src);
                    COLOR = Helper.GetGB2312Value(dwVKPOS["VKPFARBE"].ToString().Trim());
                    KCOLOR = Helper.GetGB2312Value(dwVKPOS["VKPKDFARBNR"].ToString().Trim());
                    if (KCOLOR != "")
                    {
                       src = COLOR + System.Environment.NewLine + "色号:" + KCOLOR ; 
                    }
                    else
                    {
                        src = COLOR;
                    }                      
                    exAgent.SetCellValue(x, 13, src);
                    src = dwVKPOS["QTY"].ToString().Trim();
                    exAgent.SetCellValue(x, 19, System.Convert.ToDecimal(src));
                    src = dwVKPOS["VKPMEEH"].ToString().Trim();
                    exAgent.SetCellValue(x, 24, src);
                    src = dwVKPOS["WIDTH"].ToString().Trim();
                    exAgent.SetCellValue(x, 26, src);
                    src = dwVKPOS["WEIGHT"].ToString().Trim();
                    exAgent.SetCellValue(x, 29, src);
                    src = dwVKPOS["PRICE"].ToString().Trim();
                    exAgent.SetCellValue(x, 32, System.Convert.ToDecimal(src));
                    src = dwVKPOS["VALUE"].ToString().Trim();
                    exAgent.SetCellValue(x, 35, System.Convert.ToDecimal(src));
                    src = dwVKPOS["DELDAT"].ToString().Trim();
                    exAgent.SetCellValue(x, 40, src);
                    src = dwVKPOS["COMP"].ToString().Trim();
                    exAgent.SetCellValue(x + 1, 5, Helper.GetGB2312Value(src));
                    src = dwVKPOS["SUR"].ToString().Trim();
                    if (src.Substring(src.Length - 1, 1) == ";")
                    {
                        src = src.Substring(0, src.Length - 1);
                    }
                    exAgent.SetCellValue(x + 1, 20, Helper.GetGB2312Value(src));
                    x = x + 2;

                }
                DataTable tbLIEFKO = dsSource.Tables["LIEFKO"];
                DataRow dwLIEFKO = tbLIEFKO.Rows[0];

                src = dwLIEFKO["LSNAME1"].ToString().Trim();
                exAgent.SetCellValue(95, 6, Helper.GetGB2312Value(src) + "（盖章）");
                src = dwLIEFKO["LSSTRASSE1"].ToString().Trim();
                exAgent.SetCellValue(96, 6, Helper.GetGB2312Value(src).Trim());
                src = dwLIEFKO["LSAPTEL1"].ToString().Trim();
                exAgent.SetCellValue(97, 6, Helper.GetGB2312Value(src).Trim());
                src = dwLIEFKO["LSFAX"].ToString().Trim();
                exAgent.SetCellValue(98, 6, Helper.GetGB2312Value(src).Trim());
                src = dwLIEFKO["BANK"].ToString().Trim();
                exAgent.SetCellValue(99, 6, Helper.GetGB2312Value(src).Trim());
                src = dwLIEFKO["ACCOUNT"].ToString().Trim();
                exAgent.SetCellValue(100, 6, Helper.GetGB2312Value(src).Trim());

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);

            }            
        }
               
    }
}
